package com.soft.dao;

import com.soft.IBaseDao.IBaseDao;
import com.soft.pojo.Left;
import com.soft.utils.DBUtil;

import java.util.List;

/**
 * @author ruoxi
 * @create 2021-12-27 10:37
 */
public class LeaveEmpDaoImpl implements IBaseDao<Left> {
    @Override
    public int add(Left var1) {
        return 0;
    }

    @Override
    public int del(int var1) {
        return 0;
    }

    @Override
    public int update(Left var1) {
        return 0;
    }

    @Override
    public List<Left> selectByAll() {
        return DBUtil.query("select * from lizhi where state = 1", Left.class);
    }

    @Override
    public Left selectByKey(Left var1) {
        return null;
    }

    public List<Left> selectLeaveEmpByPage(int currentPage, int currentCount) {
        return DBUtil.query("select * from lizhi where state = 1 limit ?,?", Left.class, currentPage,currentCount);
    }

    public Left selectLeaveEmpById(int id){
        List<Left> lefts = DBUtil.query("select * from lizhi where id = ?", Left.class, id);
        return lefts.get(0);
    }

    public int leaveCheckPass(int eno){
        int excute = DBUtil.excute("update lizhi set state = '0' where eno = ?", eno);
        int excute1 = DBUtil.excute("delete from emp where eno = ?", eno);
        return excute+excute1;
    }

    public int leaveCheckFail(int eno){
        return DBUtil.excute("update lizhi set state = '2' where eno = ?", eno);
    }
}
